#include <QtGui/QApplication>
#include "qmlapplicationviewer.h"
#include "baza/baza.h"
#include <QtDeclarative>
#include <QDeclarativeContext>
#include <QList>
#include "baza/popis.h"
#include "qmlhandler.h"

#include "languageitem.h"
#include "groupitem.h"
#include "listitem.h"

Q_DECL_EXPORT int main(int argc, char *argv[])
{
    Baza *database = new Baza("mobBaza");

    QApplication *app(createApplication(argc, argv));
    QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create());
    QDeclarativeContext *ctxt = viewer->rootContext();
    QMLHandler *qmlHandler = new QMLHandler(database, ctxt, app);

    qmlRegisterType<QMLHandler>("QMLHandler", 1,0, "QMLHandler");
    qmlRegisterType<LanguageItem>("LanguageItem", 1, 0, "LanguageItem");
    qmlRegisterType<GroupItem>("GroupItem", 1, 0, "GroupItem");
    qmlRegisterType<ListItem>("ListItem", 1, 0, "ListItem");
    qmlRegisterType<ItemItem>("ItemItem", 1, 0, "ItemItem");
    qmlRegisterType<ListModel>("ListModel", 1, 0, "ListModel");

    //postavljanje jezika
    Jezik odabrani=database->dajOdabraniJezik();
    qmlHandler->loadTranslation(odabrani.dajSifruJezika());

    ctxt->setContextProperty("qmlHandler", qmlHandler);

    viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);

    viewer->setMainQmlFile("qrc:/qml/qml/ducanko/main.qml");

    viewer->showExpanded();

    return app->exec();
}
